#ifndef GX_FR_EDITOR_PROPERTY_SHEET_H
#define GX_FR_EDITOR_PROPERTY_SHEET_H

#include "LibGL/GxUI.h"

namespace FinalRendering
{
	namespace Editor
	{
		using namespace GxLibBasic;

		class PropertyItem : public Object
		{
		private:
			String Name;
			String Value;
			RefPtr<GxRendering::UI::Label> lblTitle, lblValue;
		public:
			bool Pickable;
			bool ReadOnly;
			PropertyItem(const String & name, const String & value, bool pickable, bool readonly);
			String GetName();
			String GetValue();
			void SetName(const String & name);
			void SetValue(const String & value);
			void Draw(int x, int y, int w, int titleWidth, int h, bool drawValue);
		};

		class PropertySheet : public GxRendering::UI::Container
		{
		protected:
			static const int ItemHeight = 18;
			GxRendering::UI::ScrollBar2 * sb;
			GxRendering::UI::TextBox * text;
			GxRendering::UI::Button * btnPick;
			String lstText;
		protected:
			Array<RefPtr<PropertyItem>> items;
			int titleWidth;
			int SelectedIndex;
			bool draggingSplitter;
			void btnPickClicked(GxRendering::UI::UI_Base * sender);
			void PositEditControl();
			void ChangeSelectedIndex(int selID);
			void UpdateProperty(int selID, const String & value);
			void TextLostFocus(GxRendering::UI::UI_Base * sender);
		public:
			void AddPropertyItem(PropertyItem * item);
			void Clear();
			Event<String> PickProperty;
			Event<String, String, bool &> PropertyChanged;
			PropertySheet();
			void SetProperty(const String & propName, const String & value);
			void SizeChanged();
			void Draw(int absX, int absY);
			void DoMouseDown(int X, int Y, GxRendering::UI::SHIFTSTATE Shift);
			void DoMouseUp(int X, int Y, GxRendering::UI::SHIFTSTATE Shift);
			void DoMouseMove(int X, int Y);
			void DoKeyDown(unsigned short Key, GxRendering::UI::SHIFTSTATE Shift);
			
		};
	}
}

#endif